<?php
/**
  *
  *  %YJ_TITLE%     游记标题
  *  %YJ_LINK%     游记连接
  *  %YJ_SPOTS%     游记对应的景点名
  *  %YJ_PROVINCE%     游记对应的省份名
  *  %YJ_CITY%     游记对应的城市名
  *  %YJ_COUNTRY%     游记对应的国家名
  *  %USER_OWNER%   游记作者
  *  %SITE_NAME%     站点名称 自游网
  *  %WEIBO_AT%     （分享自 @自游网旅游攻略） 占位
  *  %FM_URL%   足迹分享url
  *  %FM_WANT_NUM% 想要去的足迹数量
  *  %FM_HAD_NUM% 已经去过的足迹数量
  *  %FM_NUM% 总共的足迹数量
  *  %FM_USER_NAME% 足迹作者名字
  */
function share_youji($type,$youji_node,$service=NULL){
    if($type&&($group_id=V("-:wb_share/".$type))){
        $text=APP::MOD('feed_template')->getTemplate($group_id);
        //$text=$text['template'];
        if($text){
            
            $text=strtr($text,array("%YJ_TITLE%"=>$youji_node['title'],
                                    "%YJ_LINK%"=>W_BASE_HTTP . URL("youji",array("id"=>$youji_node["id"],'_SR'=>($type=='YOUJI_PIC'?'1010208173':'1010208172'))),
                                    "%YJ_SPOTS%"=>isset($youji_node['spots']['name'])?$youji_node['spots']['name']:$youji_node['spots_user'],
                                    "%YJ_PROVINCE%"=>isset($youji_node['spots']['province_name'])?$youji_node['spots']['province_name']:"",
                                    "%YJ_CITY%"=>isset($youji_node['spots']['city_name'])?$youji_node['spots']['city_name']:"",
                                    "%YJ_COUNTRY%"=>isset($youji_node['spots']['city_name'])?$youji_node['spots']['city_name']:"",
                                    "%USER_OWNER%"=>isset($youji_node['user']['nickname'])?$youji_node['user']['nickname']:"",
                                    "%SITE_NAME%"=>"自游网",
                                    "%WEIBO_AT%"=>"（分享自 @自游网旅游攻略）",
                                    "%AT_AUTHOR%"=>"@作者",
                                    ));
            $exchange=FALSE;
            if($service){
                if(strpos($text,"@作者")&&isset($youji_node['user']['id'])){
                    $bind_info=F::api('account/get_bind',array('uid'=>$youji_node['user']['id']));
                    switch($service){
                        case 'sina':
                            if(isset($bind_info['sina'])){
                                $text=strtr($text,array("@作者"=>"@".$bind_info['sina']['nick']));
                                $exchange=TRUE;
                            }
                            break;
                        case 'qq':
                            if(isset($bind_info['qq'])){
                                $text=strtr($text,array("@作者"=>"@".$bind_info['sina']['id']));
                                $exchange=TRUE;
                            }
                            break;
                        case 'renren':
                            if(isset($bind_info['renren'])){
                                $text=strtr($text,array("@作者"=>$bind_info['sina']['nick']));
                                $exchange=TRUE;
                            }
                            break;
                    }
                }    
            }
            if(!$exchange){
                $text=strtr($text,array("@作者"=>''));
            }
            
            
            
            return $text;
        }
        return "";
    }
    return "";
}
function share_fm($type,$fm_node,$fm_url){
    if($type&&($group_id=V("-:wb_share/".$type))){
        $text=APP::MOD('feed_template')->getTemplate($group_id);
        //$text=$text['template'];
        if($text){
            $text=strtr($text,array("%FM_WANT_NUM%"=>$fm_node['want_go'],
                                    "%FM_HAD_NUM%"=>$fm_node['have_been'],
                                    "%FM_USER_NAME%"=>$fm_node['nickname'],
                                    "%FM_NUM%"=>$fm_node['want_go']+$fm_node['have_been'],
                                    "%SITE_NAME%"=>"自游网",
                                    "%FM_URL%"=>$fm_url.'&_SR=1010208171',
                                    "%WEIBO_AT%"=>"（分享自 @自游网旅游攻略）"
                                    ));
            
            return $text;
        }
        return "";
    }
    return "";
}
?>